Skip to content

fix(aggregator): gate recordsFromProviderUsage generated_at with parseIsoDate - #7359

Merged
dezren39 merged 1 commit into
mainfrom
queue/12725-5140-generated-at-isodate
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/12725-5140-generated-at-isodate

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #5140 — remainder after PR #5176 (which gated item-history cutoffAt and coverage fetchedAt, not this field).

Change

recordsFromProviderUsage (pm-stack/aggregator/src/snapshot-records.ts) gated generated_at with Date.parse only. Date.parse accepts impossible dates (2026-02-30T10:59:33Z, 2026-04-31T10:59:33Z) and non-ISO strings (March 2, 2026), so the function yielded records whose ts fails isSnapshotRecord's strict isIsoDate gate — and the append CLI (--from-provider-usage) silently dropped the whole provider-usage snapshot.

The gate now uses parseIsoDate from validate.ts (already imported in this module; semantically identical to the isIsoDate check the store applies), so impossible/non-ISO generated_at values return [] at derivation time.

Verification

  • Reproduced on current main before the fix (laptop bun probe): 2026-02-30…, 2026-04-31…, and March 2, 2026 each yielded a record with isSnapshotRecord = false; valid control passed.
  • After the fix, the same probe returns [] for all three plus not-a-date and missing generated_at; the valid control (2026-10-26T10:59:33Z) still yields its record, passing isSnapshotRecord.
  • New regression test in test/snapshot-writers.test.ts covers the three refusals, garbage input, and the valid control.
  • bun test test/snapshot-writers.test.ts test/snapshot-retention.test.ts — 47 pass / 0 fail on the laptop.

Scope note

The Python mirror (check-usage.py, writer (c)) is not tracked in this repo, so its generated_at handling could not be verified from here; the TS gate covered by issue #5140's evidence is the one fixed. Flagging for the keeper script's owner rather than expanding scope.

Task 12725 (lane code-r).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 06:42
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e3d44c6e-f543-4cb1-9066-cd3984320700
Commits

Reviewing files that changed from the base of the PR and between ae08110 and 5180471.

Files selected for processing: 2

  • pm-stack/aggregator/src/snapshot-records.ts
  • pm-stack/aggregator/test/snapshot-writers.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T06:43:42.125355Z 5180471 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@developing-today

Copy link
Copy Markdown
Contributor

Duplicate-PR salvage note (protocol §8): PR #5173 (branch queue/8819-5140-provider-usage-date, from the earlier task 8819 pass) carries the same fix as this canonical PR #7359 — the source change is identical (recordsFromProviderUsage gate: Date.parse NaN check replaced with parseIsoDate(ts) === null; this PR additionally carries the explanatory comment). Diffed in full by lane code-l on 2026-11-08: the only difference is test form — PR #5173s test also runs the valid control through the Codex windows (expecting 3 records) where this PRs test covers the sessions record. That is a coverage variant of the same gate (the gate precedes all record derivation), not unique behavior: nothing unique to salvage into this PR. PR #5173 is being closed as the duplicate of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant